<template>
  <view>
    <view class="temp-coupon-order">
      <view class="temp-coupon-order-left">
        <image class="temp-coupon-order-left-bg" src="/static/image/coupon/detail_img_card@2x.png"></image>
        <view class="temp-coupon-order-discount-info">
          <block v-if="'1' == couponOrder.coupon.couponType">
            <text class="temp-coupon-order-icon-price">￥</text>
            <text
              class="temp-coupon-order-icon-discount">{{ formatFenMoney(couponOrder.coupon.discountAmt) }}</text>
          </block>
          <block v-if="'2' == couponOrder.coupon.couponType">
            <text class="temp-coupon-order-icon-discount">{{ couponOrder.coupon.discountAmt }}</text>
            <text class="temp-coupon-order-icon-price">折</text>
          </block>
        </view>
      </view>
      <view class="temp-coupon-order-middle">
        <view class="temp-coupon-order-middle-line1">
          <text class="temp-order-type" v-if="showOrderType && couponOrder.orderType == 6">拼团</text>
          <text>{{ couponOrder.couponName }}</text>
        </view>
        <view class="temp-coupon-order-middle-line2">
          <view class="temp-coupon-order-middle-price-info">
            <block v-if="couponOrder.exchangeRuleType == 1">
              <text>{{ couponOrder.point }}积分</text>
              <text></text>
            </block>
            <block v-else-if="couponOrder.exchangeRuleType == 2">
              <text>￥{{ formatFenMoney(couponOrder.payAmount) }}</text>
            </block>
            <block v-else-if="couponOrder.exchangeRuleType == 3">
              <text>{{ couponOrder.point }}积分+￥{{ formatFenMoney(couponOrder.payAmount) }}</text>
            </block>
          </view>
          <text class="temp-coupon-order-middle-line2-right">x1</text>
        </view>
      </view>
    </view>
    <view class="temp-coupon-order-total-info">
      共
      <text style="color: #000; font-weight: bold; font-size: 28rpx">1</text>
      件，合计：
      <view class="temp-coupon-order-price-info">
        <block v-if="couponOrder.exchangeRuleType == 1">
          <text class="temp-coupon-order-price-font">{{ couponOrder.point }}</text>
          <text>积分</text>
        </block>
        <block v-else-if="couponOrder.exchangeRuleType == 2">
          <text>￥</text>
          <text class="temp-coupon-order-price-font">{{ formatFenMoney(couponOrder.payAmount) }}</text>
        </block>
        <block v-else-if="couponOrder.exchangeRuleType == 3">
          <text class="temp-coupon-order-price-font">{{ couponOrder.point }}</text>
          <text>积分+￥</text>
          <text class="temp-coupon-order-price-font">{{ formatFenMoney(couponOrder.payAmount) }}</text>
        </block>
        <block v-else>
          <text>￥</text>
          <text class="temp-coupon-order-price-font">0</text>
        </block>
      </view>
    </view>
    <view>
      <block>
        <view class="temp-coupon-order-btn-box">
          <view v-if="couponOrder.status == '0'" class="temp-coupon-order-btn"
            style="border-color: #f12106; color: #f12106" data-type="1" @tap.stop.prevent="addToCart">
            立即购买
          </view>
          <view class="temp-coupon-order-btn" v-if="1 == couponOrder.orderType"
            style="border-color: #f12106; color: #f12106" data-type="1" @tap.stop.prevent="">
            <navigator class="coupon-item-right" hover-class="none"
              :url="'/pages/coupon/couponDetail/couponDetail?couponId=' + couponOrder.couponId + '&saleRuleId=' + couponOrder.saleRuleId">
              再次购买
            </navigator>
          </view>
          <view class="temp-coupon-order-btn" v-if="6 == couponOrder.orderType"
            style="border-color: #f12106; color: #f12106" data-type="1" @tap.stop.prevent="">
            <navigator class="coupon-item-right" hover-class="none" :url="
                                          '/couponMarketingPkg/pages/couponGroupBuy/groupBuyDetail/groupBuyDetail?id=' +
                                          couponOrder.sid +
                                          '&couponId=' +
                                          couponOrder.couponId
                                      ">
              再次购买
            </navigator>
          </view>
        </view>
      </block>
    </view>
  </view>
</template>
<script>
const app = getApp();
export default {
  props: {
    showOrderType: {
      type: Boolean,
      default: false
    },
    couponOrder: {
      type: Object,
      default: () => {}
    }
  },
  methods: {
    formatFenMoney(s) {
      if (undefined == s || '' == s || null == s) {
        return 0;
      } else {
        return (s / 100)
      }
    },
    addToCart () {
      app.globalData.toCouponPay(this.couponOrder.payId, this.couponOrder.payAmount, this.couponOrder.orderType)
    }
  }
}
</script>

<style>
@import '../../templates/zsnshTemplates.css';
</style>